Small overview of PyViz capability of data exploration¶
This notebook is intended to present an small overview of PyViz and the capability for data exploration, with interactive plots (show difference between matplotlib and bokeh). Many parts based on or copied from the official PyViz Tutorial (highly recommended for a more extensive overview of the possibilities of PyViz).
Exploring Pandas Dataframes¶
If your data is in a Pandas dataframe, it’s natural to explore it using the .plot() method (based on Matplotlib). Let’s have a look at some automatic weather station data from Langenferner:
import pandas as pd
url = 'https://cluster.klima.uni-bremen.de/~oggm/tutorials/aws_data_Langenferner_UTC+2.csv'
df = pd.read_csv(url, index_col=0, parse_dates=True)
df.head()
| TEMP | RH | SWIN | SWOUT | LWIN | LWOUT | WINDSPEED | WINDDIR | PRESSURE | |
|---|---|---|---|---|---|---|---|---|---|
| 2013-07-13 00:00:00 | 1.634333 | 67.595753 | 0.0 | 0.0 | 212.744817 | 303.656833 | 4.436833 | 211.533333 | 692.622250 |
| 2013-07-13 01:00:00 | 1.388667 | 68.150512 | 0.0 | 0.0 | 209.781683 | 302.588717 | 5.544000 | 206.166667 | 692.395683 |
| 2013-07-13 02:00:00 | 1.064500 | 66.853977 | 0.0 | 0.0 | 207.234933 | 300.872133 | 5.573167 | 210.750000 | 692.200800 |
| 2013-07-13 03:00:00 | 0.985167 | 55.827547 | 0.0 | 0.0 | 207.913533 | 295.684267 | 3.970167 | 203.250000 | 692.163967 |
| 2013-07-13 04:00:00 | 1.155333 | 43.371014 | 0.0 | 0.0 | 211.513517 | 292.688400 | 3.267000 | 203.366667 | 692.001667 |
pd.__version__
'1.2.0'
Just calling .plot() won’t give anything meaningful, because of the different magnitudes of the parameters:
df.plot();
Of course we can have a look at one variable only:
df.TEMP.plot();
This creates a static plot using matplotlib. With this approach we also can make some further explorations, like calculating the monthly mean temperature:
dfm = df.resample('m').mean()
dfm.TEMP.plot();
We can see the course of the parameter but we can not tell what was the exact temperature at January and we also cannot zoom in.
Exploring Data with hvPlot and Bokeh¶
If we are using hvplot instead we can create interactive plots with the same plotting API:
import hvplot.pandas
df.TEMP.hvplot()
Now you have an interactive plot using bokeh with zooming option and hover with additional information (get the exact values and timestamps), also possible for all varaiables but again not very meaningful:
hvplot = df.hvplot()
hvplot
But at least you can use your mouse to hover over each variable and explore their values. Furthermore, by clicking on the legend the colors can be switched on/off. Still, different magnitudes make it hard to see all parameters at once.
Here the interactive features are provided by the Bokeh JavaScript-based plotting library. But what’s actually returned by this call is a overlay of something called a HoloViews object, here specifically a HoloViews Curve. HoloViews objects display as a Bokeh plot, but they are actually much richer objects that make it easy to capture your understanding as you explore the data.
print(hvplot)
:NdOverlay [Variable]
:Curve [index] (value)
This object can be converted to a HoloMap object (using the HoloViews Package and declare bokeh to use for plotting) to create a widget that can be used to select the variables from.
import holoviews as hv
hv.extension('bokeh')
holo_plot = hv.HoloMap(hvplot)
print(holo_plot)
:HoloMap [Variable]
:Curve [index] (value)
holo_plot.opts(width=700, height=500)
But first have a look at the HoloViews Objects.
HoloViews Objects¶
Creating a simple HoloViews Object:
import numpy as np
xs = np.arange(-10, 10.5, 0.5)
ys = 100 - xs**2
df_xy = pd.DataFrame(dict(x=xs, y=ys))
simple_curve = hv.Curve(df_xy, 'x', 'y')
print(simple_curve)
:Curve [x] (y)
:Curve [x] (y) is HoloViews’s shorthand for saying that the data in df_xy is a set of samples from a continuous function y of one independent variable x, and simple_curve simply pairs your dataframe df_xy with this semantic declaration.
Once we’ve captured this crucial bit of metadata, HoloViews now knows enough about this object to represent it graphically, as it will do by default in a Jupyter notebook:
simple_curve
This Bokeh plot is much more convenient to examine than a column of numbers, because it conveys the entire set of data in a compact, easily appreciated, interactively explorable format. HoloViews knew that a continuous curve like this is the right representation for what would otherwise be just a table of numbers, because we explicitly declared the element type as hv.Curve. Crucially, simple_curve itself is not a plot, it’s just a simple wrapper around your data that happens to have a convenient graphical representation. The full dataframe will always be available as simple_curve.data, for any numerical computations you would like to do:
simple_curve.data.tail()
| x | y | |
|---|---|---|
| 36 | 8.0 | 36.00 |
| 37 | 8.5 | 27.75 |
| 38 | 9.0 | 19.00 |
| 39 | 9.5 | 9.75 |
| 40 | 10.0 | 0.00 |
As you can see, with HoloViews you don’t have to select between plotting your data and working with it numerically. Any HoloViews object will let you do both conveniently; you can simply choose whatever representation is the most appropriate way to approach the task you are doing. This approach is very different from a traditional plotting program, where the objects you create (e.g. a Matplotlib figure or a native Bokeh plot) are a dead end from an analysis perspective, useful only for plotting.
HoloViews Elements¶
Holoview objects merge the visualization with the data. For an Holoview object you have to classify what the data is showing. A Holoview object could be initialised in several ways:
hv.Element(data, kdims=None, vdims=None, **kwargs)
This standard signature consists of the same five types of information:
Element: any of the dozens of element types shown in the reference gallery.data: your data in one of a number of formats described below, such as tabular dataframes or multidimensional gridded Xarray or Numpy arrays.kdims: “key dimension(s)”, also called independent variables or index dimensions in other contexts—the values for which your data was measured.vdims: “value dimension(s)”, also called dependent variables or measurements—what was measured or recorded for each value of the key dimensions.kwargs: optional keyword arguments specific to thatElementtype (rarely needed).
Elements could be for example Curve, Scatter, Area and also different ways of declaring the key dimension(s) and value dimension(s) are shown below:
(hv.Curve(df_xy, kdims=('x','x_label'), vdims=('y','y_label')) +
hv.Scatter((xs,ys)).redim.label(x='x_label', y='ylabel') +
hv.Area({'x':xs,'y':ys}))
The example also shows two ways of labeling the variables, one is directly by the initialisation with tuples ('x','x_label') and ('y','y_label') and a other option is to use .redim.label().
The example above also shows the simple syntax to create a layout of different Holoview Objects by using +. With * you can simply overlay the objects in one plot:
from holoviews import opts
(hv.Curve(df_xy, 'x', 'y') *
hv.VLine(5).opts(color='black') *
hv.HLine(75).opts(color='red'))
With .opts() you can change some characteristics of the Holoview Objects and you can use the [tab] key completion to see, what options are available or you can use the hv.help() function to get more information about some Elements.
hv.help(hv.Curve)
Curve
Online example: http://holoviews.org/reference/elements/bokeh/Curve.html
-------------
Style Options
-------------
alpha, color, hover_alpha, hover_color, hover_line_alpha, hover_line_color, line_alpha, line_cap, line_color, line_dash, line_join, line_width, muted, muted_alpha, muted_color, muted_line_alpha, muted_line_color, nonselection_alpha, nonselection_color, nonselection_line_alpha, nonselection_line_color, selection_alpha, selection_color, selection_line_alpha, selection_line_color, visible
(Consult bokeh's documentation for more information.)
------------
Plot Options
------------
The plot options are the parameters of the plotting class:
Parameters of 'CurvePlot'
=========================
Parameters changed from their default values are marked in red.
Soft bound values are marked in cyan.
C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
Name Value Type Bounds Mode
active_tools [] List (0, None) V RW
align 'start' ObjectSelector V RW
apply_extents True Boolean (0, 1) V RW
apply_ranges True Boolean (0, 1) V RW
aspect None Parameter V RW AN
bgcolor None ClassSelector V RW AN
border 10 Number V RW
data_aspect None Number V RW AN
default_span 2.0 ClassSelector V RW
default_tools ['save', 'pan', 'wheel_zoom', 'box_zo... List (0, None) V RW
finalize_hooks [] HookList (0, None) V RW
fontscale None Number V RW AN
fontsize {'title': '12pt'} Parameter V RW AN
frame_height None Integer (0, None) V RW AN
frame_width None Integer (0, None) V RW AN
gridstyle {} Dict V RW
height 300 Integer (0, None) V RW AN
hooks [] HookList (0, None) V RW
interpolation 'linear' ObjectSelector V RW
invert_axes False Boolean (0, 1) V RW
invert_xaxis False Boolean (0, 1) V RW
invert_yaxis False Boolean (0, 1) V RW
labelled ['x', 'y'] List (0, None) V RW
lod {'factor': 10, 'interval': 300, 'thre... Dict V RW
logx False Boolean (0, 1) V RW
logy False Boolean (0, 1) V RW
margin None Parameter V RW AN
max_height None Integer (0, None) V RW AN
max_width None Integer (0, None) V RW AN
min_height None Integer (0, None) V RW AN
min_width None Integer (0, None) V RW AN
normalize True Boolean (0, 1) V RW
padding (0, 0.1) ClassSelector V RW
projection None Parameter V RW AN
responsive False ObjectSelector V RW
shared_axes True Boolean (0, 1) V RW
shared_datasource True Boolean (0, 1) V RW
show_frame True Boolean (0, 1) V RW
show_grid False Boolean (0, 1) V RW
show_legend True Boolean (0, 1) V RW
show_title True Boolean (0, 1) V RW
title '{label} {group} {dimensions}' String V RW
title_format None String V RW AN
toolbar 'right' ObjectSelector V RW
tools [] List (0, None) V RW
width 300 Integer (0, None) V RW AN
xaxis 'bottom' ObjectSelector V RW
xformatter None ClassSelector V RW AN
xlabel None String V RW AN
xlim (nan, nan) Tuple V RW
xrotation None Integer (0, 360) V RW AN
xticks None Parameter V RW AN
yaxis 'left' ObjectSelector V RW
yformatter None ClassSelector V RW AN
ylabel None String V RW AN
ylim (nan, nan) Tuple V RW
yrotation None Integer (0, 360) V RW AN
yticks None Parameter V RW AN
zlim (nan, nan) Tuple V RW
Parameter docstrings:
=====================
active_tools: Allows specifying which tools are active by default. Note
that only one tool per gesture type can be active, e.g.
both 'pan' and 'box_zoom' are drag tools, so if both are
listed only the last one will be active.
align: Alignment (vertical or horizontal) of the plot in a layout.
apply_extents: Whether to apply extent overrides on the Elements
apply_ranges: Whether to compute the plot bounds from the data itself.
aspect: The aspect ratio mode of the plot. By default, a plot may
select its own appropriate aspect ratio but sometimes it may
be necessary to force a square aspect ratio (e.g. to display
the plot as an element of a grid). The modes 'auto' and
'equal' correspond to the axis modes of the same name in
matplotlib, a numeric value specifying the ratio between plot
width and height may also be passed. To control the aspect
ratio between the axis scales use the data_aspect option
instead.
bgcolor: If set bgcolor overrides the background color of the axis.
border: Minimum border around plot.
data_aspect: Defines the aspect of the axis scaling, i.e. the ratio of
y-unit to x-unit.
default_span: Defines the span of an axis if the axis range is zero, i.e. if
the lower and upper end of an axis are equal or no range is
defined at all. For example if there is a single datapoint at
0 a default_span of 2.0 will result in axis ranges spanning
from -1 to 1.
default_tools: A list of plugin tools to use on the plot.
finalize_hooks: Deprecated; use hooks options instead.
fontscale: Scales the size of all fonts.
fontsize: Specifies various fontsizes of the displayed text.
Finer control is available by supplying a dictionary where any
unmentioned keys reverts to the default sizes, e.g:
{'ticks': '20pt', 'title': '15pt', 'ylabel': '5px', 'xlabel': '5px'}
frame_height: The height of the component (in pixels). This can be either
fixed or preferred height, depending on height sizing policy.
frame_width: The width of the component (in pixels). This can be either
fixed or preferred width, depending on width sizing policy.
gridstyle: Allows customizing the grid style, e.g. grid_line_color defines
the line color for both grids while xgrid_line_color exclusively
customizes the x-axis grid lines.
height: The height of the component (in pixels). This can be either
fixed or preferred height, depending on height sizing policy.
hooks: Optional list of hooks called when finalizing a plot. The
hook is passed the plot object and the displayed element, and
other plotting handles can be accessed via plot.handles.
interpolation: Defines how the samples of the Curve are interpolated,
default is 'linear', other options include 'steps-mid',
'steps-pre' and 'steps-post'.
invert_axes: Whether to invert the x- and y-axis
invert_xaxis: Whether to invert the plot x-axis.
invert_yaxis: Whether to invert the plot y-axis.
labelled: Whether to plot the 'x' and 'y' labels.
lod: Bokeh plots offer "Level of Detail" (LOD) capability to
accommodate large (but not huge) amounts of data. The available
options are:
* factor : Decimation factor to use when applying
decimation.
* interval : Interval (in ms) downsampling will be enabled
after an interactive event.
* threshold : Number of samples before downsampling is enabled.
* timeout : Timeout (in ms) for checking whether interactive
tool events are still occurring.
logx: Whether the x-axis of the plot will be a log axis.
logy: Whether the y-axis of the plot will be a log axis.
margin: Allows to create additional space around the component. May
be specified as a two-tuple of the form (vertical, horizontal)
or a four-tuple (top, right, bottom, left).
max_height: Minimal height of the component (in pixels) if height is adjustable.
max_width: Minimal width of the component (in pixels) if width is adjustable.
min_height: Minimal height of the component (in pixels) if height is adjustable.
min_width: Minimal width of the component (in pixels) if width is adjustable.
normalize: Whether to compute ranges across all Elements at this level
of plotting. Allows selecting normalization at different levels
for nested data containers.
padding: Fraction by which to increase auto-ranged extents to make
datapoints more visible around borders.
To compute padding, the axis whose screen size is largest is
chosen, and the range of that axis is increased by the
specified fraction along each axis. Other axes are then
padded ensuring that the amount of screen space devoted to
padding is equal for all axes. If specified as a tuple, the
int or float values in the tuple will be used for padding in
each axis, in order (x,y or x,y,z).
For example, for padding=0.2 on a 800x800-pixel plot, an x-axis
with the range [0,10] will be padded by 20% to be [-1,11], while
a y-axis with a range [0,1000] will be padded to be [-100,1100],
which should make the padding be approximately the same number of
pixels. But if the same plot is changed to have a height of only
200, the y-range will then be [-400,1400] so that the y-axis
padding will still match that of the x-axis.
It is also possible to declare non-equal padding value for the
lower and upper bound of an axis by supplying nested tuples,
e.g. padding=(0.1, (0, 0.1)) will pad the x-axis lower and
upper bound as well as the y-axis upper bound by a fraction of
0.1 while the y-axis lower bound is not padded at all.
projection: Allows supplying a custom projection to transform the axis
coordinates during display. Example projections include '3d'
and 'polar' projections supported by some backends. Depending
on the backend custom, projection objects may be supplied.
responsive: < No docstring available >
shared_axes: Whether to invert the share axes across plots
for linked panning and zooming.
shared_datasource: Whether Elements drawing the data from the same object should
share their Bokeh data source allowing for linked brushing
and other linked behaviors.
show_frame: Whether or not to show a complete frame around the plot.
show_grid: Whether to show a Cartesian grid on the plot.
show_legend: Whether to show legend for the plot.
show_title: Whether to display the plot title.
title: The formatting string for the title of this plot, allows defining
a label group separator and dimension labels.
title_format: Alias for title.
toolbar: The toolbar location, must be one of 'above', 'below',
'left', 'right', None.
tools: A list of plugin tools to use on the plot.
width: The width of the component (in pixels). This can be either
fixed or preferred width, depending on width sizing policy.
xaxis: Whether and where to display the xaxis.
The "bare" options allow suppressing all axis labels, including ticks and xlabel.
Valid options are 'top', 'bottom', 'bare', 'top-bare' and 'bottom-bare'.
xformatter: Formatter for ticks along the x-axis.
xlabel: An explicit override of the x-axis label, if set takes precedence
over the dimension label.
xlim: User-specified x-axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.
xrotation: Rotation angle of the xticks.
xticks: Ticks along x-axis specified as an integer, explicit list of
tick locations, or bokeh Ticker object. If set to None default
bokeh ticking behavior is applied.
yaxis: Whether and where to display the yaxis.
The "bare" options allow suppressing all axis labels, including ticks and ylabel.
Valid options are 'left', 'right', 'bare', 'left-bare' and 'right-bare'.
yformatter: Formatter for ticks along the x-axis.
ylabel: An explicit override of the y-axis label, if set takes precedence
over the dimension label.
ylim: User-specified x-axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.
yrotation: Rotation angle of the yticks.
yticks: Ticks along y-axis specified as an integer, explicit list of
tick locations, or bokeh Ticker object. If set to None
default bokeh ticking behavior is applied.
zlim: User-specified z-axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.
So now we can use some Holoview object for the data exploration for the glacier data. We create a Layout with some subplots for the different parameters. With opts.defaults() we can change some default properties of the different HoloView Elements, here we activate the hover tool for all Curve elements. Try to zoom into one plot!
opts.defaults(opts.Curve(tools=['hover']))
(hv.Curve(df, 'index', 'TEMP') +
hv.Curve(df,'index','RH') +
hv.Curve(df,'index','SWIN').opts(color='darkorange') * hv.Curve(df,'index','SWOUT').opts(color='red') +
hv.Curve(df,'index','LWIN').opts(color='darkorange') * hv.Curve(df,'index','LWOUT').opts(color='red') +
hv.Curve(df,'index','WINDSPEED') +
hv.Curve(df,'index','WINDDIR')).cols(3).opts(opts.Curve(width=300, height=200))
So here we created a Curve Element for some Parameters and put them together in subplots by using + and overlay some in one subplot with *. With .opts() I define the color of some parameters and set the width and height propertie for the used Curve Elements and with .cols() I define the number of columns.
Now we can zoom in and use a hover for data exploration and because all Holoview Objects using the same dataframe and the same key variable the x-axes of all plots are linked. So when you zoom in in one plot all the other plots are zoomed in as well.
HoloView Dataset and HoloMap Objects¶
A HoloViews Dataset is similar to a HoloViews Element, without having any specific metadata that lets it visualize itself. A Dataset is useful for specifying a set of Dimensions that apply to the data, which will later be inherited by any visualizable elements that you create from the Dataset.
A HoloViews Dimension is the same concept as a dependent or independent variable in mathematics. In HoloViews such variables are called value dimensions and key dimensions (respectively). So lets take again our glacier pandas DataFrame and create a HoloView Dataset. Beforehand we define some new columns for the date. Then we create our HoloView DataFrame with the key variables (independent) month, year and day_hour. The remaining columns will automatically be inferred to be value (dependent) dimensions:
df['month'] = df.index.month_name()
df['year'] = df.index.year
df['day_hour'] = df.index.day + df.index.hour/24
df['timestamp'] = df.index.strftime('%d.%m.%Y %H:%M')
df_month = hv.Dataset(df, ['month', 'year', 'day_hour'])
df_month = df_month.redim.label(day_hour='day of month')
df_month
:Dataset [month,year,day_hour] (TEMP,RH,SWIN,SWOUT,LWIN,LWOUT,WINDSPEED,WINDDIR,PRESSURE,timestamp)
Out of this Dataset we now can create a Holomap with .to. The .to method of a Dataset takes up to four main arguments:
The element you want to convert to
The key dimensions (i.e., independent variables) to display
The dependent variables to display, if any
The dimensions to group by, if nothing given the remaining key variables are used
slider = df_month.to(hv.Curve, ['day_hour'], ['TEMP', 'RH', 'SWIN', 'timestamp'])
slider = slider.opts(width=600, height=400, tools=['hover'])
print(slider)
:HoloMap [month,year]
:Curve [day_hour] (TEMP,RH,SWIN,timestamp)
We now created a HoloMap with to grouped variables [month, year], one key variable [day_hour] and five dependent variables (TEMP, RH, SWIN, WINDSPEED, timestamp). Now look at the viasualisation:
slider
We see that a widget was created where we can choose the 'month' and the 'year' (the two grouped variables). The plot is showing the 'day_hour' (key) variable against the first dependent variable 'TEMP'. The other dependent variables are not shown but their values are displayed in the hover.
For a better comparison we also can look at grouped variables at once when we use .overlay():
overlay = df_month.to(hv.Curve, ['day_hour'], ['TEMP', 'RH', 'SWIN','WINDSPEED','timestamp']).overlay().opts(width=800, height=500,
tools=['hover'])
overlay.opts(opts.NdOverlay(legend_muted=True, legend_position='left'))
print(overlay)
:NdOverlay [month,year]
:Curve [day_hour] (TEMP,RH,SWIN,WINDSPEED,timestamp)
Here we are creating an NdOverlay Object which is similar to a HoloMap, but has a different visualisation:
overlay
Here now no widget is created, instead there is a interactive legend where we can turn the color on by clicking in the legend on it. So we can compare the months with each other (for example the same month in different years).
It is also easy to look at some mean values, for example looking at mean diurnal values for each month and year you can use .aggregate, which combine the values after the given function:
df['hour'] = df.index.hour
df_mean = hv.Dataset(df, ['month', 'year', 'hour']).aggregate(function=np.mean)
df_mean = df_mean.redim.label(hour='hour of the day')
print(df_mean)
:Dataset [month,year,hour] (TEMP,RH,SWIN,SWOUT,LWIN,LWOUT,WINDSPEED,WINDDIR,PRESSURE,day_hour)
.aggregate() therfore is using the key variables and looking were all of them are the same and using the provided function (in the case above np.mean) to calculate new values. So in the above case we calculating mean daily cycles for each month and year. The calculated Dataset than can be displayed as we had seen it above.
slider = df_mean.to(hv.Curve, ['hour'], ['TEMP', 'RH', 'SWIN']).opts(width=600, height=400, tools=['hover'])
print(slider)
slider
:HoloMap [month,year]
:Curve [hour] (TEMP,RH,SWIN)
overlay = df_mean.to(hv.Curve, ['hour'], ['TEMP', 'RH', 'SWIN']).opts(width=600, height=400, tools=['hover']).overlay()
overlay.opts( opts.NdOverlay(legend_muted=True, legend_position='left'))
print(overlay)
overlay
:NdOverlay [month,year]
:Curve [hour] (TEMP,RH,SWIN)
Using GeoView for displaying geographical data¶
As a small example for using geoview I want to show how to display a shapefiles of glaciers in an interactive plot.
import geoviews as gv
import geopandas as gpd
Tile sources¶
Tile sources are very convenient ways to provide geographic context for a plot and they will be familiar from the popular mapping services like Google Maps and Openstreetmap. The WMTS element provides an easy way to include such a tile source in your visualization simply by passing it a valid URL template. GeoViews provides a number of useful tile sources in the gv.tile_sources module:
import geoviews.tile_sources as gts
layout = gv.Layout([ts.relabel(name) for name, ts in gts.tile_sources.items()])
layout.opts('WMTS', xaxis=None, yaxis=None, width=225, height=225).cols(4)
To read the shape file geopandas could be used:
from oggm import utils
europe_glacier = gpd.read_file(utils.get_rgi_region_file('11', version='61'))
hintereisferner = europe_glacier[europe_glacier.Name == 'Hintereisferner'].geometry.iloc[0]
Than creating an GeoViews Object, with an GeoViews Element Shape, display it it put an gv.tile_sources in the background.
hv.help(gv.Shape)
Shape
Help for the data object: holoviews.help(Shape) or holoviews.help(<shape_instance>)
-------------
Style Options
-------------
alpha, cmap, color, fill_alpha, fill_color, hover_alpha, hover_color, hover_fill_alpha, hover_fill_color, hover_line_alpha, hover_line_color, line_alpha, line_cap, line_color, line_dash, line_join, line_width, muted, muted_alpha, muted_color, muted_fill_alpha, muted_fill_color, muted_line_alpha, muted_line_color, nonselection_alpha, nonselection_color, nonselection_fill_alpha, nonselection_fill_color, nonselection_line_alpha, nonselection_line_color, selection_alpha, selection_color, selection_fill_alpha, selection_fill_color, selection_line_alpha, selection_line_color, visible
(Consult bokeh's documentation for more information.)
------------
Plot Options
------------
The plot options are the parameters of the plotting class:
Parameters of 'GeoShapePlot'
============================
Parameters changed from their default values are marked in red.
Soft bound values are marked in cyan.
C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
Name Value Type Bounds Mode
active_tools [] List (0, None) V RW
align 'start' ObjectSelector V RW
apply_extents True Boolean (0, 1) V RW
apply_ranges True Boolean (0, 1) V RW
aspect None Parameter V RW AN
bgcolor None ClassSelector V RW AN
border 10 Number V RW
cformatter None ClassSelector V RW AN
clabel None String V RW AN
clim (nan, nan) Tuple V RW
clim_percentile False ClassSelector V RW
clipping_colors {} Dict V RW
cnorm 'linear' ObjectSelector V RW
color_index 0 ClassSelector V RW AN
color_levels None ClassSelector V RW AN
colorbar False Boolean (0, 1) V RW
colorbar_opts {} Dict V RW
colorbar_position 'right' ObjectSelector V RW
data_aspect None Number V RW AN
default_span 2.0 ClassSelector V RW
default_tools ['save', 'pan', WheelZoomTool(id='810... List (0, None) V RW
finalize_hooks [] HookList (0, None) V RW
fixed_bounds False Boolean (0, 1) V RW
fontscale None Number V RW AN
fontsize {'title': '12pt'} Parameter V RW AN
frame_height None Integer (0, None) V RW AN
frame_width None Integer (0, None) V RW AN
global_extent False Boolean (0, 1) V RW
gridstyle {} Dict V RW
height 300 Integer (0, None) V RW AN
hooks [] HookList (0, None) V RW
infer_projection False Boolean (0, 1) V RW
invert_axes False Boolean (0, 1) V RW
invert_xaxis False Boolean (0, 1) V RW
invert_yaxis False Boolean (0, 1) V RW
labelled ['x', 'y'] List (0, None) V RW
legend_cols False Integer V RW
legend_muted False Boolean (0, 1) V RW
legend_offset (0, 0) NumericTuple V RW
legend_opts {} Dict V RW
legend_position 'top_right' ObjectSelector V RW
lod {'factor': 10, 'interval': 300, 'thre... Dict V RW
logx False Boolean (0, 1) V RW
logy False Boolean (0, 1) V RW
logz False Boolean (0, 1) V RW
margin None Parameter V RW AN
max_height None Integer (0, None) V RW AN
max_width None Integer (0, None) V RW AN
min_height None Integer (0, None) V RW AN
min_width None Integer (0, None) V RW AN
normalize True Boolean (0, 1) V RW
padding 0.1 ClassSelector V RW
projection <cartopy.crs.Mercator object at 0x7f7... Parameter V RW
responsive False ObjectSelector V RW
selected None List (0, None) V RW AN
shared_axes True Boolean (0, 1) V RW
shared_datasource True Boolean (0, 1) V RW
show_bounds False Boolean (0, 1) V RW
show_frame True Boolean (0, 1) V RW
show_grid False Boolean (0, 1) V RW
show_legend False Boolean (0, 1) V RW
show_title True Boolean (0, 1) V RW
symmetric False Boolean (0, 1) V RW
title '{label} {group} {dimensions}' String V RW
title_format None String V RW AN
toolbar 'right' ObjectSelector V RW
tools [] List (0, None) V RW
width 300 Integer (0, None) V RW AN
xaxis 'bottom' ObjectSelector V RW
xformatter None ClassSelector V RW AN
xlabel None String V RW AN
xlim (nan, nan) Tuple V RW
xrotation None Integer (0, 360) V RW AN
xticks None Parameter V RW AN
yaxis 'left' ObjectSelector V RW
yformatter None ClassSelector V RW AN
ylabel None String V RW AN
ylim (nan, nan) Tuple V RW
yrotation None Integer (0, 360) V RW AN
yticks None Parameter V RW AN
zlim (nan, nan) Tuple V RW
Parameter docstrings:
=====================
active_tools: Allows specifying which tools are active by default. Note
that only one tool per gesture type can be active, e.g.
both 'pan' and 'box_zoom' are drag tools, so if both are
listed only the last one will be active.
align: Alignment (vertical or horizontal) of the plot in a layout.
apply_extents: Whether to apply extent overrides on the Elements
apply_ranges: Whether to compute the plot bounds from the data itself.
aspect: The aspect ratio mode of the plot. By default, a plot may
select its own appropriate aspect ratio but sometimes it may
be necessary to force a square aspect ratio (e.g. to display
the plot as an element of a grid). The modes 'auto' and
'equal' correspond to the axis modes of the same name in
matplotlib, a numeric value specifying the ratio between plot
width and height may also be passed. To control the aspect
ratio between the axis scales use the data_aspect option
instead.
bgcolor: If set bgcolor overrides the background color of the axis.
border: Minimum border around plot.
cformatter: Formatter for ticks along the colorbar axis.
clabel: An explicit override of the color bar label. If set, takes precedence
over the title key in colorbar_opts.
clim: User-specified colorbar axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.
clim_percentile: Percentile value to compute colorscale robust to outliers. If
True, uses 2nd and 98th percentile; otherwise uses the specified
numerical percentile value.
clipping_colors: Dictionary to specify colors for clipped values, allows
setting color for NaN values and for values above and below
the min and max value. The min, max or NaN color may specify
an RGB(A) color as a color hex string of the form #FFFFFF or
#FFFFFFFF or a length 3 or length 4 tuple specifying values in
the range 0-1 or a named HTML color.
cnorm: Color normalization to be applied during colormapping.
color_index: Deprecated in favor of color style mapping, e.g. `color=dim('color')`
color_levels: Number of discrete colors to use when colormapping or a set of color
intervals defining the range of values to map each color to.
colorbar: Whether to display a colorbar.
colorbar_opts: Allows setting specific styling options for the colorbar overriding
the options defined in the colorbar_specs class attribute. Includes
location, orientation, height, width, scale_alpha, title, title_props,
margin, padding, background_fill_color and more.
colorbar_position: Allows selecting between a number of predefined colorbar position
options. The predefined options may be customized in the
colorbar_specs class attribute.
data_aspect: Defines the aspect of the axis scaling, i.e. the ratio of
y-unit to x-unit.
default_span: Defines the span of an axis if the axis range is zero, i.e. if
the lower and upper end of an axis are equal or no range is
defined at all. For example if there is a single datapoint at
0 a default_span of 2.0 will result in axis ranges spanning
from -1 to 1.
default_tools: A list of plugin tools to use on the plot.
finalize_hooks: Deprecated; use hooks options instead.
fixed_bounds: Whether to prevent zooming beyond the projections defined bounds.
fontscale: Scales the size of all fonts.
fontsize: Specifies various fontsizes of the displayed text.
Finer control is available by supplying a dictionary where any
unmentioned keys reverts to the default sizes, e.g:
{'ticks': '20pt', 'title': '15pt', 'ylabel': '5px', 'xlabel': '5px'}
frame_height: The height of the component (in pixels). This can be either
fixed or preferred height, depending on height sizing policy.
frame_width: The width of the component (in pixels). This can be either
fixed or preferred width, depending on width sizing policy.
global_extent: Whether the plot should display the whole globe.
gridstyle: Allows customizing the grid style, e.g. grid_line_color defines
the line color for both grids while xgrid_line_color exclusively
customizes the x-axis grid lines.
height: The height of the component (in pixels). This can be either
fixed or preferred height, depending on height sizing policy.
hooks: Optional list of hooks called when finalizing a plot. The
hook is passed the plot object and the displayed element, and
other plotting handles can be accessed via plot.handles.
infer_projection: Whether the projection should be inferred from the element crs.
invert_axes: Whether to invert the x- and y-axis
invert_xaxis: Whether to invert the plot x-axis.
invert_yaxis: Whether to invert the plot y-axis.
labelled: Whether to plot the 'x' and 'y' labels.
legend_cols: Whether to lay out the legend as columns.
legend_muted: Controls whether the legend entries are muted by default.
legend_offset: If legend is placed outside the axis, this determines the
(width, height) offset in pixels from the original position.
legend_opts: Allows setting specific styling options for the colorbar.
legend_position: Allows selecting between a number of predefined legend position
options. The predefined options may be customized in the
legend_specs class attribute.
lod: Bokeh plots offer "Level of Detail" (LOD) capability to
accommodate large (but not huge) amounts of data. The available
options are:
* factor : Decimation factor to use when applying
decimation.
* interval : Interval (in ms) downsampling will be enabled
after an interactive event.
* threshold : Number of samples before downsampling is enabled.
* timeout : Timeout (in ms) for checking whether interactive
tool events are still occurring.
logx: Whether the x-axis of the plot will be a log axis.
logy: Whether the y-axis of the plot will be a log axis.
logz: Whether to apply log scaling to the z-axis.
margin: Allows to create additional space around the component. May
be specified as a two-tuple of the form (vertical, horizontal)
or a four-tuple (top, right, bottom, left).
max_height: Minimal height of the component (in pixels) if height is adjustable.
max_width: Minimal width of the component (in pixels) if width is adjustable.
min_height: Minimal height of the component (in pixels) if height is adjustable.
min_width: Minimal width of the component (in pixels) if width is adjustable.
normalize: Whether to compute ranges across all Elements at this level
of plotting. Allows selecting normalization at different levels
for nested data containers.
padding: Fraction by which to increase auto-ranged extents to make
datapoints more visible around borders.
To compute padding, the axis whose screen size is largest is
chosen, and the range of that axis is increased by the
specified fraction along each axis. Other axes are then
padded ensuring that the amount of screen space devoted to
padding is equal for all axes. If specified as a tuple, the
int or float values in the tuple will be used for padding in
each axis, in order (x,y or x,y,z).
For example, for padding=0.2 on a 800x800-pixel plot, an x-axis
with the range [0,10] will be padded by 20% to be [-1,11], while
a y-axis with a range [0,1000] will be padded to be [-100,1100],
which should make the padding be approximately the same number of
pixels. But if the same plot is changed to have a height of only
200, the y-range will then be [-400,1400] so that the y-axis
padding will still match that of the x-axis.
It is also possible to declare non-equal padding value for the
lower and upper bound of an axis by supplying nested tuples,
e.g. padding=(0.1, (0, 0.1)) will pad the x-axis lower and
upper bound as well as the y-axis upper bound by a fraction of
0.1 while the y-axis lower bound is not padded at all.
projection: Allows supplying a custom projection to transform the axis
coordinates during display. Defaults to GOOGLE_MERCATOR.
responsive: < No docstring available >
selected: The current selection as a list of integers corresponding
to the selected items.
shared_axes: Whether to invert the share axes across plots
for linked panning and zooming.
shared_datasource: Whether Elements drawing the data from the same object should
share their Bokeh data source allowing for linked brushing
and other linked behaviors.
show_bounds: Whether to show gridlines on the plot.
show_frame: Whether or not to show a complete frame around the plot.
show_grid: Whether to show gridlines on the plot.
show_legend: Whether to show legend for the plot.
show_title: Whether to display the plot title.
symmetric: Whether to make the colormap symmetric around zero.
title: The formatting string for the title of this plot, allows defining
a label group separator and dimension labels.
title_format: Alias for title.
toolbar: The toolbar location, must be one of 'above', 'below',
'left', 'right', None.
tools: A list of plugin tools to use on the plot.
width: The width of the component (in pixels). This can be either
fixed or preferred width, depending on width sizing policy.
xaxis: Whether and where to display the xaxis.
The "bare" options allow suppressing all axis labels, including ticks and xlabel.
Valid options are 'top', 'bottom', 'bare', 'top-bare' and 'bottom-bare'.
xformatter: Formatter for ticks along the x-axis.
xlabel: An explicit override of the x-axis label, if set takes precedence
over the dimension label.
xlim: User-specified x-axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.
xrotation: Rotation angle of the xticks.
xticks: Ticks along x-axis specified as an integer, explicit list of
tick locations, or bokeh Ticker object. If set to None default
bokeh ticking behavior is applied.
yaxis: Whether and where to display the yaxis.
The "bare" options allow suppressing all axis labels, including ticks and ylabel.
Valid options are 'left', 'right', 'bare', 'left-bare' and 'right-bare'.
yformatter: Formatter for ticks along the x-axis.
ylabel: An explicit override of the y-axis label, if set takes precedence
over the dimension label.
ylim: User-specified x-axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.
yrotation: Rotation angle of the yticks.
yticks: Ticks along y-axis specified as an integer, explicit list of
tick locations, or bokeh Ticker object. If set to None
default bokeh ticking behavior is applied.
zlim: User-specified z-axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.
(gv.Shape(hintereisferner).opts(fill_color=None) *
gts.tile_sources['EsriImagery']).opts(width=800, height=500)
The GeoViews Object and Element is similar to HoloViews Objects and Elements for geographical data.
print(gv.Shape(hintereisferner))
:Shape [Longitude,Latitude]
And so similar a visualisation is stored for each GeoView Element, which can be used like an HoloView Object. So as an last example you also can plot all European glaciers in one interactive plot by using an Polygons Element of GeoViews:
(gv.Polygons(europe_glacier)*
gts.tile_sources['StamenTerrain']).opts(width=800, height=500)



